import 'package:development_assistant/config/db_config.dart';
import 'package:sqflite/sqlite_api.dart';
import '../model/server_info.dart';

class ServerService{

  Database database=DBConfig.getDatabase();

  final String tableName="server_info";

  Future getServerList() async{
    return await database.query(tableName);
  }

  Future getServerInfo(int? serverID) async{
    return await database.query(tableName,where:"server_id=?",whereArgs: [serverID]);
  }

  Future addServer(ServerInfo server) async{
    return await database.insert(tableName, server.toMap());
  }

  Future updateServer(ServerInfo server) async{
    return await database.update(tableName, server.toMap(),where:"server_id=?",whereArgs: [server.serverID]);
  }

  Future delServer(int serverID) async{
    return await database.delete(tableName,where:"server_id=?",whereArgs: [serverID]);
  }

}